using System;

using ScenarioFramework.WorkflowEngine.DataModel.WorkflowParticipantsData;

namespace ScenarioFramework.WAPI
{
	/// <summary>
	/// Descrizione di riepilogo per wrpWAPIActivity.
	/// </summary>
	public partial class User
	{
		/// <summary>
		/// Initializes a new instance  of the <see cref="User"/> class.
		/// </summary>
		private User()
		{
		}

        /// <summary>
        /// Gets the users.
        /// </summary>
        /// <returns></returns>
        public static XMLUsers GetUsers()
        {
            Response response = new Response();

            string sUsers = WAPI.User.GetUsers(ref response);

            if (response.iCode != 0)
                throw new Exception.WAPIException(response.iCode, response.sMsg);

            XMLUsers xmlUsers = new XMLUsers();
            xmlUsers.Parse(sUsers);

            return xmlUsers;
        }

        public static Boolean Authenticate(String userId, String password)
        {
            Response response = new Response();
            int iAuthenticate = WAPI.User.Authenticate(userId, password, ref response);

            if (response.iCode != 0)
                throw new Exception.WAPIException(response);

            if (iAuthenticate == 0)
                return false;
            else
                return true;
        }
	}
}
